package com.timo.rabbitmq.controller;

import com.timo.constant.RabbitMqConstant;
import com.timo.constant.RabbitMqConstant.*;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @Description: 类用途：
 * @Author: Timo
 * @Date: 2019/7/24 09:54
 */
@RestController
@RequestMapping("/topic")
public class TopicController {

    @Resource
    private RabbitTemplate rabbitTemplate;


    @GetMapping("/hello")
    public void hello() {
        rabbitTemplate.convertAndSend(TopicExchangeEnum.FOO_TOPIC_EXCHANGE.name,"foo.#","timo Order buy or hello");
    }

    @GetMapping("/test")
    public void test() {
        rabbitTemplate.convertAndSend(TopicExchangeEnum.FOO_TOPIC_EXCHANGE.name,"foo.topic.queue","timo Order buy or hello");
    }

    @GetMapping("/insert")
    public void insert() {
        rabbitTemplate.convertAndSend(TopicExchangeEnum.FOO_TOPIC_EXCHANGE.name,"foo.insert.topic.queue","foo insert");
    }

    @GetMapping("/update")
    public void update() {
        rabbitTemplate.convertAndSend(TopicExchangeEnum.FOO_TOPIC_EXCHANGE.name,"foo.update.topic.queue","foo update");
    }

    @GetMapping("/delete")
    public void delete() {
        rabbitTemplate.convertAndSend(TopicExchangeEnum.FOO_TOPIC_EXCHANGE.name,"foo.delete.topic.queue","foo delete");
    }


}
